package cn.ekuma.epos.analysis.singleproduct.model;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import com.openbravo.bean.erp.viewbean.ProductTransaction;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;


public class ProductTransactionTableModel extends AbstractTableModel{
    
	List<ProductTransaction>  rows;
    

    public ProductTransactionTableModel() {
        rows=new ArrayList();
    }

    public void resert( List<ProductTransaction> rows){
        this.rows=rows;
        this.fireTableStructureChanged();
    }

	@Override
	public int getColumnCount() {
		return COLUMNS_Pref.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		ProductTransaction obj=rows.get(rowIndex);
		switch(columnIndex){
		case 0:
			return Formats.TIMESTAMP.formatValue(obj.getCurDate());
		case 1:
			return obj.getOrderTypeName();
		case 2:
			return obj.getOrderType();
		case 3:
			return obj.getMultiply();
		}
		return null;
	}
    
	
	
	@Override
	public Class<?> getColumnClass(int columnIndex) {
		if(columnIndex==3)
			return Double.class;
		return super.getColumnClass(columnIndex);
	}

	public int getRowCount() {
        return rows.size();
    }
	
	 public String getColumnName(int column) {
		 return COLUMNS_Pref[column];
	 }
	 
	 public static String[] COLUMNS_Pref=new String[]{
		 AppLocal.getIntString("label.date"),
		 AppLocal.getIntString("label.ordertype"),
		 AppLocal.getIntString("label.ordertypedialog.bearing"),
		 AppLocal.getIntString("label.units")
  };

	
	
}
